package com.gorkr;

/**
 * @author gorkr
 * @title: O04
 * @projectName my-leetcode
 * @description: 二维数组中的查找
 * @date 2021/12/1622:22
 */
public class O04 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int n = matrix.length-1;  // 行
        if(n<0)return false;
        int m = matrix[n].length-1;  // 列
        int i = 0;
        while (i<=n&&m>=0){
            if(matrix[i][m]==target){
                return true;
            }else if(matrix[i][m]>target){
                m--;
            }else if(matrix[i][m]<target){
                i++;
            }
        }
        return false;

    }

}
